#include<vector>
#include<iostream>
#include<thread>
using namespace std;

class Base {
public:
	virtual void func() = 0;

	~Base() {
		this_thread::sleep_for(std::chrono::seconds(10));
	}
};

class Derive :public Base {
public:
	void func()final {
		cout << "virtual Derive::func" << endl;
	}
};
//class Derive1 :public Derive {
//public:
//	void func() {
//		cout << "virtual Derive::func" << endl;
//	}
//};

void work(Base* pb) {
	while (pb != NULL) {
		pb->func();
	}
}

int main() {
	Base* pd = new Derive();
	pd->func();
	thread th(work, pd);
	delete pd;
	pd = NULL;
	th.join();
}